import com.sun.deploy.util.LinkMouseListener;

public class TestMain {
    public static void main(String[] args) {

        MyLinkedList linkedList = new MyLinkedList();

//        linkedList.addAtHead(1);
//        linkedList.addAtTail(3);
//        printListNode(linkedList);
//        linkedList.addAtIndex(1, 2);   //链表变为1-> 2-> 3
//        printListNode(linkedList);
//        System.out.println(linkedList.get(1));            //返回2
//        linkedList.deleteAtIndex(1);  //现在链表是1-> 3
//        System.out.println(linkedList.get(1));            //返回3

//        linkedList.addAtHead(1);
//        linkedList.deleteAtIndex(0);
//        printListNode(linkedList);


//        linkedList.addAtIndex(0,10);
//        linkedList.addAtIndex(0,20);
//        linkedList.addAtIndex(1,30);
//        System.out.println(linkedList.get(0));
//        printListNode(linkedList);

//      ["MyLinkedList","addAtHead","deleteAtIndex","addAtHead","addAtHead","addAtHead","addAtHead","addAtHead","addAtTail","get","deleteAtIndex","deleteAtIndex"]
//      [[],            [2],        [1],            [2],[7],[3],[2],[5],[5],[5],[6],[4]]

//      ["MyLinkedList","addAtIndex","get","deleteAtIndex"]
//      [[],[-1,0],[0],[-1]]
        linkedList.addAtIndex(-1,0);
        System.out.println(linkedList.get(0));
        linkedList.deleteAtIndex(-1);
        linkedList.deleteAtIndex(1);
        printListNode(linkedList);


    }

    public static void printListNode(MyLinkedList linkedList){
        ListNode head = linkedList.head;
        while (head.next != null){
            System.out.print(head.next.val + " ");
            head = head.next;
        }
        System.out.println();
    }
}
